package com.programs.waw;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import android.text.ClipboardManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import android.widget.Toast;

public class SingleResultView extends Activity implements OnClickListener {

	private String ssid;
	private String wpa;
	private String model;
	private int color;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.single_result);

		Intent intent = getIntent();

		ssid = intent.getStringExtra(getPackageName() + ".ssid");
		wpa = intent.getStringExtra(getPackageName() + ".wpa");
		model = intent.getStringExtra(getPackageName() + ".model");
		color = intent.getIntExtra(getPackageName() + ".color", 0);

		View view = findViewById(R.id.elementSingleResult);
		view.setOnClickListener(this);
		View connectButton = findViewById(R.id.connection_button);
		connectButton.setOnClickListener(this);

		((TextView) findViewById(R.id.ssidTextSingleResult)).setText(ssid);
		((TextView) findViewById(R.id.wpaStringSingleResult)).setText(wpa);

		TextView modelTextView = ((TextView) findViewById(R.id.modelString));
		modelTextView.setText(model);
		modelTextView.setTextColor(color);

	}

	@Override
	public void onClick(View v) {

		switch (v.getId()) {

		case R.id.elementSingleResult:

			ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
			clipboard.setText(wpa);
			Toast.makeText(getApplicationContext(),
					"Stringa copiata negli appunti", Toast.LENGTH_LONG).show();
			break;
		case R.id.connection_button:

			startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
			break;

		default:
			break;
		}

	}
}
